package com.lingchen.response;


import com.lingchen.enums.ResultEnum;

/**
 * Author    lingchen
 * Email     838878458@qq.com
 * Time      2017/11/29
 * Function  返回工具类
 */
public class ResultUtil {

    public static <T> Result<T> success() {
        return new Result<T>(null);
    }

    public static <T> Result<T> success(T data) {
        return new Result<T>(data);
    }

    public static <T> Result<T> error(ResultEnum resultEnum) {
        return error(resultEnum.getCode(), resultEnum.getMessage());
    }


    public static <T> Result<T> error(String message) {
        return new Result<T>(0, message);
    }

    public static <T> Result<T> error(int code, String message) {
        return new Result<T>(code, message);
    }

}
